package com.hkbigdata.sybx.service.ipml;

/**
 * @author yangjing
 * @creat 2025-05-28-9:01
 * @email 3010335359@qq.com
 */

import com.hkbigdata.sybx.bean.UserLoginRecord;
import com.hkbigdata.sybx.mapper.UserLoginRecordMapper;
import com.hkbigdata.sybx.service.UserLoginRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserLoginRecordServiceImpl implements UserLoginRecordService {

    @Autowired
    private UserLoginRecordMapper userLoginRecordMapper;

    @Override
    public String insertLoginRecord(UserLoginRecord userLoginRecord) {
        // 检查必填字段
        if (userLoginRecord.getUser_id() == null) {
            throw new IllegalArgumentException("用户ID不能为空");
        }
        int result = userLoginRecordMapper.addLoginRecord(userLoginRecord);
        return result > 0 ? "success" : "fail";
    }

    @Override
    public List<UserLoginRecord> getLoginRecordsByUserId(Long user_id) {
        return userLoginRecordMapper.getLoginRecordsByUserId(user_id.toString());
    }
}